Skip to content

[TT-16950] fix: set nonroot ownership on application files#8019

Closed
buger wants to merge 1 commit intorelease-5.12.1from
hotfix/fix-nonroot-permissions
Closed

[TT-16950] fix: set nonroot ownership on application files#8019
buger wants to merge 1 commit intorelease-5.12.1from
hotfix/fix-nonroot-permissions

Conversation

@buger
Copy link
Copy Markdown
Member

@buger buger commented Apr 15, 2026

$(gh pr view 8019 --repo TykTechnologies/tyk --json body -q .body)

Related Tickets

Add --chown=65532:65532 to COPY in Dockerfile.distroless.
Fixes permission denied when gateway writes to middleware/bundles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@buger buger requested a review from a team as a code owner April 15, 2026 10:33
@probelabs
Copy link
Copy Markdown
Contributor

probelabs Bot commented Apr 15, 2026

This pull request addresses a file permission issue in the distroless Docker image that occurs when running the container as a non-root user. The fix involves adding the --chown=65532:65532 flag to the COPY instruction in the Dockerfile, ensuring that the /opt/tyk-gateway directory is owned by the non-root user. This prevents the mkdir /opt/tyk-gateway/middleware/bundles: permission denied error at runtime.

Files Changed Analysis

  • ci/Dockerfile.distroless: Modified to change file ownership during the Docker build process.
    • 1 addition, 1 deletion.

Architecture & Impact Assessment

  • Accomplishment: Fixes a runtime permission error for users following security best practices by running the Tyk Gateway container with a non-root user.
  • Technical Change: Introduces the --chown flag in the COPY command within ci/Dockerfile.distroless to set the owner of the application files to the non-root user (UID 65532).
  • Affected Components: This change impacts the build process of the distroless Docker image for Tyk Gateway. It directly affects the runtime environment of the container, specifically when a non-root security context is enforced.

Scope Discovery & Context Expansion

  • The change is highly targeted, affecting only the distroless Docker image build. The error message mkdir .../middleware/bundles: permission denied indicates a failure during the gateway's initialization when it attempts to write middleware bundle files.
  • This fix aligns the file system permissions with the intended non-root execution user of the container, a common practice for enhancing security.
  • While the change is isolated to one file, it suggests a broader operational context of running Tyk in secured, production-like environments. Other Dockerfiles or deployment scripts in the repository might warrant a review for similar permission issues.
Metadata
  • Review Effort: 1 / 5
  • Primary Label: bug

Powered by Visor from Probelabs

Last updated: 2026-04-15T10:35:28.132Z | Triggered by: pr_opened | Commit: 185b531

💡 TIP: You can chat with Visor using /visor ask <your question>

@probelabs
Copy link
Copy Markdown
Contributor

probelabs Bot commented Apr 15, 2026

✅ Security Check Passed

No security issues found – changes LGTM.

✅ Security Check Passed

No security issues found – changes LGTM.

\n\n

Architecture Issues (1)

Severity Location Issue
🟡 Warning ci/Dockerfile.distroless:17
The UID and GID `65532` are hard-coded in the `COPY` instruction. This couples the image to a specific user ID, which can cause permission issues in environments that enforce different UIDs for security reasons (e.g., OpenShift). This reduces the image's portability and flexibility.
💡 SuggestionTo make the image more adaptable, define the UID and GID using build arguments (`ARG`) and reference them in the `--chown` flag. This allows the user/group to be configured at build time. For example: ```dockerfile ARG TYK_UID=65532 ARG TYK_GID=65532

COPY --chown=${TYK_UID}:${TYK_GID} --from=deb /opt/tyk-gateway /opt/tyk-gateway

</details>
</div></td>
    </tr>
  </tbody>
</table>
<!-- visor:section-end id="architecture" -->

<!-- visor:section={"id":"performance","revision":2} -->
### ✅ Performance Check Passed

**No performance issues found – changes LGTM.**
<!-- visor:section-end id="performance" -->

<!-- visor:section={"id":"quality","revision":2} -->

<!-- visor:section-end id="quality" -->

<!-- visor:thread-end key="TykTechnologies/tyk#8019@185b531" -->

---

*Powered by [Visor](https://probelabs.com/visor) from [Probelabs](https://probelabs.com)*

*Last updated: 2026-04-15T10:35:08.774Z | Triggered by: pr_opened | Commit: 185b531*

💡 **TIP:** You can chat with Visor using `/visor ask <your question>`
<!-- /visor-comment-id:visor-thread-review-TykTechnologies/tyk#8019 -->

@github-actions
Copy link
Copy Markdown
Contributor

API Changes

no api changes detected

@ilijabojanovic ilijabojanovic added the deps-reviewed Dependency changes reviewed and approved for CI execution label Apr 15, 2026
@probelabs probelabs Bot added the bug label Apr 15, 2026
@probelabs probelabs Bot changed the title fix: set nonroot ownership on application files [TT-16950] fix: set nonroot ownership on application files Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Jira Linter Failed

Commit: 185b531
Failed at: 2026-04-15 10:48:56 UTC

The Jira linter failed to validate your PR. Please check the error details below:

🔍 Click to view error details
failed to validate branch and PR title rules: branch name 'hotfix/fix-nonroot-permissions' must contain a valid Jira ticket ID (e.g., ABC-123)

Next Steps

  • Ensure your branch name contains a valid Jira ticket ID (e.g., ABC-123)
  • Verify your PR title matches the branch's Jira ticket ID
  • Check that the Jira ticket exists and is accessible

This comment will be automatically deleted once the linter passes.

@buger buger closed this Apr 15, 2026
@buger buger deleted the hotfix/fix-nonroot-permissions branch April 15, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug deps-reviewed Dependency changes reviewed and approved for CI execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants